/*****************************************************************************
*        描述 :
*             文件描述
*        CLR版本:            3.5
*        创建者 :            蒋 光
*        个人域名:           jiangguang.net.cn
*        命名空间名称:       ECP.DataAccess
*        文件名:             BaseDelegationDao.cs
*        创建系统时间:       2012/11/2 19:06:59
*        创建年份:           2012
*
/*****************************************************************************/

namespace ECP.DataAccess
{
    using ECP.DataAccess.Utilities;
    using ECP.Model;
    using ECP.Utilities;

    public class BaseDelegationDao : BaseDao
    {
        public BaseDelegationDao()
        {
            base.CurrentTableName = BaseDelegationTable.TableName;
        }

        public BaseDelegationDao(IDbHelper dbHelper)
            : this()
        {
            base.DbHelper = dbHelper;
        }

        public BaseDelegationDao(BaseUserInfo userInfo)
            : this()
        {
            base.UserInfo = userInfo;
        }

        public BaseDelegationDao(IDbHelper dbHelper, BaseUserInfo userInfo)
            : this(dbHelper)
        {
            base.UserInfo = userInfo;
        }

        public string Add(string consignerID, string delegantID)
        {
            string sequence = BaseSequenceDao.Instance.GetSequence(base.DbHelper, BaseDelegationTable.TableName);
            SQLBuilder builder = new SQLBuilder(base.DbHelper);
            builder.BeginInsert(BaseDelegationTable.TableName);
            builder.SetValue(BaseDelegationTable.FieldID, sequence);
            builder.SetValue(BaseDelegationTable.FieldConsignerID, consignerID);
            builder.SetValue(BaseDelegationTable.FieldDelegantID, delegantID);
            builder.SetValue(BaseDelegationTable.FieldCreateUserID, base.UserInfo.ID);
            builder.SetDBNow(BaseDelegationTable.FieldCreateDate);
            if (builder.EndInsert() <= 0)
            {
                return string.Empty;
            }
            return sequence;
        }
    }
}